const app = getApp()

Page({
  /**
   * 页面的初始数据
   */
  data: {
		focus:false,
		is_shwo:false,
		config:{},
		group:{},
    store:[],
	},
	//打开载入
  onLoad: function (options) {
    app.getParam(options,(param) => {
			if(!app.util().isNull(param.group_id)){
				this.data.id = parseInt(param.group_id)
				this.apiGroup();
			}else{
				this.setData({
					focus:true
				})
			}
		});
	},
	onSearch:function(e){
		if(e.detail != null){
			this.data.id = parseInt(e.detail)
			this.apiGroup();
		}else(
			this.data.id = 0
		)
	},
	//获取API
	apiGroup: function () {
		var parms = {
			id: this.data.id,
		}
		app.api().Get('api/v1/smartbc/group/groupInfo',parms,(result) => {
			if (result.code == 200) {
				this.setData({
					group:result.data,
					is_shwo:true
				})
				this.apiGroupStore();
			}else{
				this.setData({
					is_shwo:false
				})
			}
		})
	},
	//获取API
	apiGroupStore: function () {
		app.api().Get('api/v1/smartbc/group/groupStore',{id: this.data.id,type:0},(result) => {
			if (result.code == 200) {
				this.setData({
					store:result.data,
				})
			}
		})
	},
	//申请入圈
	apiGroupOperate: function () {
		app.api().Get('api/v1/smartbc/group/groupAdd',{id:this.data.id},(result) => {
			app.wxAlert(result.msg,() =>{
				wx.navigateBack({
					delta:1
				})
			})
		}) 
	}
})